import requests
import conf
import os
def download_video(video_url:str,video_name:str) -> None:
    headers_ = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
        'Referer': video_url,
    }
    response = requests.get(video_url, stream=True, headers=headers_)

    # 检查请求是否成功
    if response.status_code == 200:
        # 打开一个本地文件用于保存下载的视频
        with open(f'{os.path.join(conf.video_download_path,video_name)}.mp4', 'wb') as f:
            # 下载大文件需这样处理
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)
        print("下载完成")
    else:
        print("错误", response.status_code)

